<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\DB;
use phpDocumentor\Reflection\DocBlock\Tags\See;
use Illuminate\Support\Facades\Session;

class CheckAdmin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * 检测后台管理员登陆人员是否为允许的人;
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $mgid = Session::get("mgid");
        if($mgid){
            //如果存在session，则继续正常执行
            return $next($request);
        }else{
            //否则就跳转到登录页面
            return redirect('/login');
        }
    }
}
